package com.it;

public class SeasonsDemo {
    public static void main(String[] args) {
        //获取春天对象
        Seasons enum1 = Seasons.SPRING;
        System.out.println(enum1);


        System.out.println("-------------");

        //switch搭配enum使用，可以不用谢default，因为enum已经做了限制
        switch (enum1) {
            case SPRING:
                System.out.println("春天");
                break;
            case SUMMER:
                System.out.println("夏天");
                break;
            case AUTUMN:
                System.out.println("秋天");
                break;
            case WINTER:
                System.out.println("冬天");
                break;
        }

        System.out.println("--------------");


        Seasons[] seasons = Seasons.values();//获取所有枚举的数组对象
        //遍历枚举
        for (int i = 0; i < seasons.length; i++) {
            System.out.println(seasons[i]);
        }
    }
}
